<template>
  <div class="home" >
    <a-button type="primary">这里是首页</a-button>
    <img alt="Vue logo" src="../assets/logo.png" />
    <router-link to="/login">登录页</router-link>
    <router-link to="/main/xqbz/initial">需求编制</router-link>
    <router-link to="/main/xqbz/task">任务库</router-link>
    <a-button type="primary" @click="createInstance">点击创建新的 Vue 实例</a-button>
    <a-button type="primary" @click="createDialog">创建一个 Vue 弹框 实例</a-button>
    <a-button type="primary" @click="test">点击测试</a-button>
    <a-button type="primary" @click="previewFile">文件预览</a-button>
    <div id="myhome"></div>
    <a-modal v-model:visible="visibldde" title="Basic Modal">
      <p>Some 法第三方士大夫发...</p>
      <p>Some contents...</p>
      <p>Some contents...</p>
    </a-modal>
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
import Antd from 'ant-design-vue';
import { createApp, ref, h } from 'vue'
import router from '@/router'
import test from '@/views/test'
import store from '@/store'

import {ConfigProvider} from 'ant-design-vue'

console.log('test  查看 test 组件 ++++++++++++++++++++  ')
console.log(test)
console.log(ConfigProvider)

import createInstance1 from '@/plugin/createInstance'
import dialogTest from '@/views/dialogTest'
import zhCN from 'ant-design-vue/es/locale/zh_CN';
// import { useRouter } from "vue-router";
export default {
  name: 'Home',
  components: {
    HelloWorld
  },
  setup(){

    const visibldde = ref(false)

    const previewFile = () => {
      $g.previewFile('https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.xlsx')
    }

    function createInstance(){
      visibldde.value = true
      const div = document.getElementById('myhome')
      createApp(test).use(Antd).use(router).use(store).mount(div)

    }

    const createDialog = () => {
      createInstance1(dialogTest)
    }

    const tests = () => {


      const instance =  $g.createInstance(dialogTest, {
        time: new Date().getTime(),
        fn(){
          console.log('fn 执行了 ++++++++++++++++++++++++++++++++++')
          console.log(instance.instanceRef)
        }
      })

      setTimeout(() => {
        console.log('查看 instance ')
        console.log(instance)
        instance.instanceRef.value.list[0] = new Date().getTime()
      }, 2000)

      
    //   const abGb = {
    //     template: '<h1>这是我需要验证的  组件</h1>',
    //   }

    //   const app = createApp({
    //     render(){
    //       return h(
    //         ConfigProvider,
    //         { locale: zhCN },
    //         h( dialogTest )
    //       )
    //     }
    //   })

    //  app.use(Antd)


    //   const dom = document.createElement('div')
    //   document.body.appendChild(dom)

    //   app.mount(dom)
    }

    

    return {createInstance, createDialog, visibldde, test:tests, previewFile}
    // return () => {
    //   return h('h1', null, 'fsdfsfsdfsf')
    // }
  },
  // render(){
  //   console.log('我已经 render  了')
  //   return h('h1', null, '我是 发顺丰是发斯蒂芬斯蒂芬是的方式发生的发生的')
  // }
}
</script>
